package com.linzm.leetcode.primary.exercises3_20230122;

/**
 * @Author zimingl
 * @Date 2023/1/23 22:31
 * @Description: 统计特殊四元组
 */
public class Demo10_1995 {

    public static void main(String[] args) {
        Demo10_1995 demo10_1995 = new Demo10_1995();
        int[] nums = {1,1,1,3,5};
        int quadruplets = demo10_1995.countQuadruplets(nums);
        System.out.println(quadruplets);
    }

    private int countQuadruplets(int[] nums) {
        int n = nums.length, ans = 0;
        for (int a = 0; a < n; a++) {
            for (int b = a + 1; b < n; b++) {
                for (int c = b + 1; c < n; c++) {
                    for (int d = c + 1; d < n; d++) {
                        if (nums[a] + nums[b] + nums[c] == nums[d]) ans++;
                    }
                }
            }
        }
        return ans;
    }
}
